//
//  TrainVideoWebViewController.m
//  ExpandTableView
//
//  Created by ZYK on 16/2/16.
//  Copyright © 2016年 ZYK. All rights reserved.
//

#import "TrainVideoWebViewController.h"

@interface TrainVideoWebViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *indicator;

@end

@implementation TrainVideoWebViewController

#pragma mark - View LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self preferredInterfaceOrientationForPresentation];
    
    self.view.backgroundColor = [UIColor colorWithHex:0xf3f3f3];
    self.webView.backgroundColor = [UIColor colorWithHex:0xf3f3f3];
    
    self.webView.delegate = self;
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self.urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    request.HTTPShouldHandleCookies = YES;
     [self.webView loadRequest: request];
}

- (void)dealloc
{
    [self.webView stopLoading];
    self.webView.delegate = nil;
}

#pragma mark - UIWebViewDelegate

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [self.indicator startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self.indicator stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [self.indicator stopAnimating];
}


#pragma mark - Rotate

//屏幕横屏
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

//限制屏幕横屏和录制视频横屏
-(BOOL)shouldAutorotate{
    return NO;
}



@end
